package com.furns.dao.impl;

import com.furns.dao.BasicDAO;
import com.furns.dao.OrderItemDAO;
import com.furns.entity.Order;
import com.furns.entity.OrderItem;

import java.util.List;

/**
 * @Author LuoJiaCheng
 * @ID 2240129126
 * @Version 1.0
 */
public class OrderItemDAOImpl extends BasicDAO<OrderItem> implements OrderItemDAO {

    @Override
    public int saveOrderItem(OrderItem orderItem) {
        String sql="INSERT INTO `order_item`(`id`,`name`,`price`,`count`,`total_price`,`order_id`)\n" +
                "VALUES(?,?,?,?,?,?)";
        return update(sql,orderItem.getId(),orderItem.getName(),orderItem.getPrice(),orderItem.getCount(),orderItem.getTotal_price(),orderItem.getOrder_id());
    }

    @Override
    public List<OrderItem> showOrderItem(String orderId) {
        String sql="select id,name,price,count,total_price,order_id from order_item where order_id=?";
        List<OrderItem> orderItems = queryMulti(sql, OrderItem.class, orderId);
        return orderItems;
    }
}
